import { _decorator, Component, Label, Node } from 'cc';
const { ccclass, property } = _decorator;
import axios from 'axios';

import * as cc from 'cc';
@ccclass('userMenu')
export class userMenu extends Component {
    @property(Node)
    private myUrl: Node = null;

    @property(Node)
    private myName: Node = null;

    //初始化头像和名字
    // onLoad() {
    //     let avatarUrl = globalThis._userInfo.user_head_url;
    //     if(avatarUrl.length<20)return;
    //     console.log('头像地址 = ', avatarUrl);
    //     let that = this;
    //     cc.assetManager.loadRemote(avatarUrl, { ext: '.jpg' }, function (err, imageAsset) {
    //         if (err) {
    //             cc.error(err.message || err);
    //             return;
    //         }
    //         // console.log('imageAsset类型jpg = ', imageAsset);

    //         // 创建 cc.Texture2D 对象
    //         let texture = new cc.Texture2D();
    //         // console.log('new cc.Texture2D 1 = ', texture);
    //         // texture.image = imageAsset;
    //         // console.log('new cc.Texture2D 2 = ', texture);


    //         // 创建SpriteFrame
    //         var spriteFrame = new cc.SpriteFrame();
    //         spriteFrame.texture = texture;
    //         // console.log('new cc.SpriteFrame = ', spriteFrame);

    //         // 设置Sprite的SpriteFrame
    //         that.myUrl.getComponent(cc.Sprite).spriteFrame = spriteFrame;
    //         // console.log('myUrl = ', that.myUrl);
    //         // console.log('myUrl.getComponent(cc.Sprite) = ', that.myUrl.getComponent(cc.Sprite));
    //     });

    //     let myNameString = this.myName.getComponent(cc.Label)
    //     myNameString.string = globalThis._userInfo.user_name
    // }

    //点击分享按钮 好友
    fxBtn() {
        // 小程序分享好友api
        wx.shareAppMessage({
            title: '分享给好友',
            imageUrl: globalThis._userInfo.user_head_url,
            success: function () {
                console.log('分享成功');
            },
            fail: function () {
                console.log('分享失败');
            }
        });
    }
    


}

